package com.zyf.project.kvdb.protocol.proto.impl;

import com.zyf.project.kvdb.protocol.constants.Constants;
import com.zyf.project.kvdb.protocol.proto.Response;
import utils.binary.impl.Bytes;

/**
 * <h1>KVDB 返回消息</h1>
 * <p>实现了 {@link Response} 接口</p>
 *
 * @author Zhou Yifan
 */
public class KVDBResponse implements Response {

    private int code;

    private Bytes[] result;

    public KVDBResponse(int code) {
        this.code = code;
    }

    public KVDBResponse(int code, Bytes... result) {
        this.code = code;
        this.result = result;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public void setResult(Bytes[] result) {
        this.result = result;
    }

    /**
     * 获取状态码
     *
     * @return 状态，{@link Constants#SUCCESS} {@link Constants#ERROR}
     */
    @Override
    public int getCode() {
        return code;
    }

    /**
     * 获取返回结果
     *
     * @return {@link Bytes} 类型数组
     */
    @Override
    public Bytes[] getResult() {
        return result;
    }
}
